import * as types from '@/store/mutation-types';
import { get } from '@/common/utils';

export default {
  state: {
    language: 'zh-CN',
  },
  mutations: {
    [types.SET_LANGUZGE_ZH](state) {
      state.language = 'zh-CN';
    },
    [types.SET_LANGUZGE_EN](state) {
      state.language = 'en-US';
    },
    [types.GET_LANGUAGE_VUEX](state, payload) {
      state.language = payload.language;
    },
  },
  actions: {
    setLanguageZH({ commit }) {
      commit(types.SET_LANGUZGE_ZH);
    },
    setLanguageEN({ commit }) {
      commit(types.SET_LANGUZGE_EN);
    },
    setLangVuex({ commit }) {
      const language = get('language');
      commit(types.GET_LANGUAGE_VUEX, { language }); // 从前面传语言的值
    },

  },
};
